﻿#ifndef CAMERALOADER_H
#define CAMERALOADER_H
#include <QLibrary>
#include <QObject>
#include "CameraFactoryInterface.h"

namespace Qly {

class CameraLoader : public QObject
{
    Q_OBJECT
public:
    explicit CameraLoader(QString dllFullName, QObject *parent = nullptr);
    ~CameraLoader();
    bool isValid();
    CameraFactoryInterface * defaultInstance();
    CameraFactoryInterface * createInstance(QObject *p);
    void release(CameraFactoryInterface * p);

private:
    QLibrary * pCameraLib;

    typedef Qly::CameraFactoryInterface * (*CreateInstanceType)(QObject *);
    typedef void (*ReleaseType)(Qly::CameraFactoryInterface *);

    CreateInstanceType CreateInstance = nullptr;
    ReleaseType Release = nullptr;

    CameraFactoryInterface * m_pInterface = nullptr;
};

}
#endif // CAMERALOADER_H
